<? 
include("protect1.php"); 
?>

<STYLE type=text/css>.blank {
	FONT-SIZE: 0px; WIDTH: 0px; HEIGHT: 0px
}
TD {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
INPUT {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
.present {
	FONT-WEIGHT: bold; BACKGROUND-COLOR: #dee5ec
}
.h1 {
	FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #ffffff
}
.d1 {
	COLOR: #c0c0c0
}
.link {
	FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: #ffffff; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.footer {
	FONT-WEIGHT: normal; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.footer1 {
	FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: url(chat/images/menu_b.gif); CURSOR: default; COLOR: #000000; BORDER-BOTTOM: 0px
}
.header {
	FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: url(chat/images/menu_h.gif); CURSOR: default; COLOR: #000000; BORDER-BOTTOM: 0px
}
.textcol {
	FONT-SIZE: 12px; COLOR: #2378d5; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}
body {
	background-color: #FFFFFF;
	background-image: url(bg.jpg);
	background-repeat: repeat;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFFFFF;
}
a:hover {
	text-decoration: underline;
	color: #021C8A;
}
a:active {
	text-decoration: none;
	color: #001D86;
}
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11pt;
	color: #FFFFFF;
}
</STYLE>

<title>:: Nilai KHS &amp; IPK ::</title><table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="7e96dc">&nbsp;</td>
  </tr>
  <tr>
    <td><img src="images/bannerAtas.jpg" alt="image" width="780" height="200" /></td>
  </tr>
  <tr>
    <td bgcolor="3a5db1">
	<?php
    $nrp=$reg_uname;
	$allsks=0;
	$allnilai=0;
	//include("banner.html");
	include("connect.php");
	$pilih=mysql_select_db("uwika_krs",$conn);
	echo "<BR>";

	$smt=0; // ditambah tuk melihat KHS & KRS yang lampau
	tampil('1/00-01',$nrp,$smt);
	tampil('2/00-01',$nrp,$smt);
	tampil('1/01-02',$nrp,$smt);
	tampil('2/01-02',$nrp,$smt);
	tampil('1/02-03',$nrp,$smt);
	tampil('2/02-03',$nrp,$smt);
	tampil('1/03-04',$nrp,$smt);
	tampil('2/03-04',$nrp,$smt);
	tampil('1/04-05',$nrp,$smt);
	tampil('2/04-05',$nrp,$smt);
	tampil('1/05-06',$nrp,$smt);
	tampil('2/05-06',$nrp,$smt);
	tampil('1/06-07',$nrp,$smt);
	tampil('2/06-07',$nrp,$smt);
	tampil('1/07-08',$nrp,$smt);
	tampil('2/07-08',$nrp,$smt);
    tampil('1/08-09',$nrp,$smt);
    tampil('2/08-09',$nrp,$smt);
    tampil('1/09-10',$nrp,$smt);
    tampil('2/09-10',$nrp,$smt);
    tampil('1/10-11',$nrp,$smt);
	tampil('2/10-11',$nrp,$smt);
	tampil('1/11-12',$nrp,$smt);
	tampil('2/11-12',$nrp,$smt);
	
	echo "<br> <div align = center>";
	echo "<font face=\"Arial\" size=4><b>";
	$allsks=0;
	//$nilai = 0;
	$sqlstr="SELECT distinct(kodemk),sks, nilai FROM `sks` WHERE nrp='$nrp'"; // and nilai <> 'BL'";
	
	$hasil=mysql_query($sqlstr);
	$row = mysql_fetch_row($hasil);
	//echo ($nrp);
	//echo ($hasil);
	do {
		list($kodemk,$sks)=$row;
		$allsks=$allsks + $sks;
		//echo ("$sks <br>");
		echo ("$nilai");
		$allnilai=$allnilai + (huruf2angka($row[2]) * $sks);
		//echo ("$allnilai <br>");
	} while ($row=mysql_fetch_row($hasil));

	echo "Total SKS yang sudah anda tempuh sampai saat ini : <font size=6 color = black><u>$allsks</u></font>";
	echo "<br>";
	echo "Nilai IPK Anda saat ini : ";
	//echo ($allnilai);
	//echo ($allsks);
	echo "<u><font size=6 color = black>" . round($allnilai / $allsks,3) . "</u></font>";
	echo "</font></b>";
	echo "<br>";

	function tampil($periode,$nrp,$smt) {
		global $smt;
		$sqlstr="select kodemk,nama,sks,nilai from sks where nrp='$nrp' and periode='$periode'";
		$hasil=mysql_query($sqlstr);
		list($kodemk) = mysql_fetch_row($hasil);
		if (!empty($kodemk)) {
			$smt=$smt + 1;
			$totsks=0;
			$totbobot=0;
			$sqlstr="select kodemk,nama,sks,nilai from sks where nrp='$nrp' and periode='$periode'";
			$hasil=mysql_query($sqlstr);
			echo "<div align = center>";
			echo "SEMESTER : <b>$smt</b> <br>";
			echo "PERIODE : <b>$periode</b>";
			echo "</div>";
			//echo "<tr><td width=5%></td><td>";
			echo "<table width=\"70%\" border=\"0\" align = center>";
			echo "<tr bgcolor=\"#001E8C\">";
			echo "<td width=\"5%\"><b><center>K O D E</center></td>";
			echo "<td width=\"20%\"><B><center>N A M A &nbsp; M A T A  &nbsp; K U L I A H</center></td>";
			echo "<td width=\"5%\"><B><center>SKS</center></td>";
			echo "<td width=\"3%\"><b><center>GRADE</center></td>";
			echo "</tr>";
			$row = mysql_fetch_row($hasil);
			$bantuan=0;
			do {
				$bantuan++;
				list($kodemk,$nama,$sks,$nilai) = $row;
				if (($bantuan % 2) == 0) {
				     echo "<tr bgcolor=\"#4585cd\">";
				} else {
					 echo "<tr bgcolor=\"#7e96dc\">";
				}
				echo "<td><center>$kodemk</center></td>";
				echo "<td>$nama</td>";
				echo "<td><center>$sks</center></td>";
				if ($nilai != 'BL') {
					$totsks=$totsks + $sks;

					$totbobot=$totbobot + (huruf2angka($nilai) * $sks);
				}		
				echo "<td><center>$nilai</center></td></tr>";
			} while ($row=mysql_fetch_row($hasil));
			echo "</table>";
			echo ("<div align = center>");
			echo "Total SKS : <b>$totsks</b> &nbsp&nbsp | &nbsp&nbsp ";
			$allsks=$allsks+$totsks;
			echo "Nilai IPS : <b> ";
			echo round($totbobot / $totsks,3);
			echo "</b> </div><br><br>";
		}
	}

	function huruf2angka($nilai) {
		switch ($nilai) {
			case "A" :
				return 4;
				break;
			case "AB" :
				return 3.5;
				break;
			case "B" :
				return 3;
				break;
			case "BC" :
				return 2.5;
				break;
			case "C" :
				return 2;
				break;
			case "D" :
				return 1;
				break;
			case "E" :
				return 0;
				break;
		}
	}
	echo "</div><br>";
	include("footer.php");
?>

	&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="7e96dc"><div align="center">copyleft L@BKOM 2009 </div></td>
  </tr>
</table>
